package com.learnyou.server.xingzuo.common.converter;

import cn.hutool.core.convert.impl.StringConverter;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author heweifeng
 * @Description:
 * @date 2022/9/1 15:22
 */
public class MyStringConverter extends StringConverter {

    @Override
    protected String convertInternal(Object value) {
        if (value instanceof List){
            List list = (List) value;
            return StrUtil.str(list.stream()
                    .map(t-> StrUtil.str(t, CharsetUtil.CHARSET_UTF_8))
                    .collect(Collectors.joining(",")), CharsetUtil.CHARSET_UTF_8);
        }
        return convertToStr(value);
    }
}
